<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <a href="javascript:;">百度</a>

    <form action="https://www.taobao.com">
        <p>
            <input type="text" name="account">
        </p>
        <p>
            <button>提交</button>
        </p>
    </form>

    <script>
        var a = document.querySelector("a");
        var btn = document.querySelector("button");
        a.addEventListener("click", function(e) {
            // e.preventDefault(); //阻止浏览器的默认行为
            console.log("被点击了！");
        })

        btn.onclick = function(e){
            return false;
            // e.preventDefault();
            // e.returnValue = false;
        }
    </script>
</body>

</html>